// @ts-ignore
/* eslint-disable */

import { request, type RequestOptions } from '@/utils/request';

// 接口暂缺类型定义，使用any代替
interface KnowledgeFileSearch extends Record<string, any> {}
interface KnowledgeFileOut extends Record<string, any> {}

/**
 * 获取知识库文件列表
 * @param input 文件搜索参数
 * @returns 
 */
export async function knowledgeFileList(input: KnowledgeFileSearch, options?: RequestOptions) {
  return request<Array<KnowledgeFileOut>>(`knowledge-base/file-list`, {
    method: 'POST',
    data: input,
    ...(options || {}),
  });
}

/**
 * 获取知识库文件详情
 * @param id 文件ID
 * @returns 
 */
export async function knowledgeFileDetail(id: string, options?: RequestOptions) {
  return request<KnowledgeFileOut>(`knowledge-base/${id}/file-detail`, {
    method: 'GET',
    params: { id },
    ...(options || {}),
  });
}

/**
 * 创建知识库文件
 * @param input 文件信息
 * @returns 
 */
export async function knowledgeFileCreate(input: any, options?: RequestOptions) {
  return request<KnowledgeFileOut>(`knowledge-base/file-create`, {
    method: 'POST',
    data: input,
    ...(options || {}),
  });
}

/**
 * 编辑知识库文件
 * @param id 文件ID
 * @param input 文件信息
 * @returns 
 */
export async function knowledgeFileUpdate(id: any, input: any, options?: RequestOptions) {
  return request<boolean>(`knowledge-base/file-edit`, {
    method: 'POST',
    data: { ...input, id: id.id },
    ...(options || {}),
  });
}

/**
 * 知识库文件向量化
 * @param knowledgeBaseId 知识库ID
 * @param fileId 文件ID
 * @returns 
 */
export async function knowledgeFileEmbedding(knowledgeBaseId: any, fileId: any, options?: RequestOptions) {
  return request<boolean>(`a-i/process-knowledge-base`, {
    method: 'POST',
    params: {
      knowledgeBaseId,
      fileId
    },
    ...(options || {}),
  });
}

/**
 * 删除知识库文件
 * @param input 文件ID信息
 * @returns 
 */
export async function knowledgeFileDelete(input: any, options?: RequestOptions) {
  return request<boolean>(`knowledge-base/${input.id}/file-delete`, {
    method: 'POST',
    ...(options || {}),
  });
} 